=== Campo RUT Chileno para WooCommerce ===
Contributors: Francisco Risi
Donate link: https://francisco.risi.cl
Tags: woocommerce, checkout, rut, chile, validation
Requires at least: 5.0
Tested up to: 6.8
Stable tag: 1.1
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Adds, validates (via AJAX), and formats the Chilean RUT field on the WooCommerce checkout page. Stores the data in the order, displays it in emails, and in the administration panel.

== Description ==

This plugin is designed specifically for Chilean WooCommerce stores. It adds a **RUT** field (Rol Único Tributario) to the checkout page, which is essential for invoicing and legal compliance in Chile.

### Features

* **Custom Field:** Adds a mandatory 'RUT' field to the Billing section of the WooCommerce checkout.
* **Live Formatting:** Automatically formats the RUT with points and the hyphen (e.g., **11.111.111-1**) as the user types, using JavaScript (AJAX) for a better user experience.
* **Live Validation:** Validates the RUT's **Dígito Verificador (DV)** in real-time on the client side, preventing invalid submissions.
* **Server Validation:** Includes robust PHP validation to ensure the RUT is valid before the order is finalized.
* **Data Storage:** The validated and formatted RUT is stored securely in the order metadata.
* **Visibility:** The RUT is displayed in:
    * The Order details page in the WordPress Admin area.
    * The Customer and Admin Order confirmation emails.

== Installation ==

1.  Upload the `campo-rut-chileno-para-woocommerce` folder (containing `rut-chileno-woo.php`, `rut-validator.js`, and this `readme.txt`) to the `/wp-content/plugins/` directory.
2.  Activate the plugin through the 'Plugins' menu in WordPress.
3.  The RUT field will automatically appear in the WooCommerce Checkout Billing section.

== Changelog ==

= 1.1 =
* **Security:** Added robust sanitization and escaping for all user inputs (`$_POST`) and outputs (Admin/Emails).
* **Fix:** Ensured live formatting and AJAX validation scripts are correctly enqueued.
* Improved PHP validation logic.

= 1.0 =
* Initial release.
* Adds RUT field to checkout.
* Basic validation and data storage.

== Frequently Asked Questions ==

= Does this plugin work with all WooCommerce themes? =
Yes, it is designed to use standard WooCommerce hooks and CSS classes and should work with most themes, including Storefront and popular builders.

= Is the RUT mandatory? =
Yes, the field is set as required (`'required' => true`) in the PHP code.

== Upgrade Notice ==

= 1.1 =
Please update for important security enhancements (sanitization and escaping) and improved validation.